package com.lmk.homework;

import java.util.Scanner;

public class work05 {
    public static void main(String[] args) {

            Scanner sc = new Scanner(System.in);
            System.out.print("请输入一个整数：");
            int n = sc.nextInt();

            ////////////  判断用户输入的是几位数
            int i = 0;
            int m = n;
            while (m > 0) {
                m /= 10;
                i++;
            }
            System.out.println("您输入的是一个" + i + "位的整数");

            ///////////  计算各位数之和
            int j = n;
            int sum = 0;
            while (j > 0) {
                sum += j % 10;
                j /= 10;
            }
            System.out.println("各位数之和位：" + sum);

            //////////// 逆序输出一个整数
            int k = n;
            int p = 0;
            while (k > 0) {
                p = p * 10 + k % 10;
                k /= 10;
            }
            System.out.println("逆序后的结果：" + p);
        }
    }
